#/**************************************************************************
# * Kevin 2014-02-24                                                       *
# **************************************************************************/

#---------------------------------------------------------------------------
# Constant Variable definition
#---------------------------------------------------------------------------

include $(TOPDIR)/Tools/toolchain.def

#---------------------------------------------------------------------------
# Target definition (User)
#---------------------------------------------------------------------------
GOAL  = $(LIB_DIR)/wmboot.$(LIBTYPE)

#---------------------------------------------------------------------------
# Source section (User)
#---------------------------------------------------------------------------
ifeq ($(ARCH_M3),1)
ASM_SRC := startup_venus.s
C_SRC := misc.c \
	 retarget.c
endif

ifeq ($(ARCH_M3),0)
ASM_SRC := start.s \
	   mpu.s
C_SRC := retarget.c
endif

#---------------------------------------------------------------------------
# Linker options
#---------------------------------------------------------------------------
LDFLAGS    += --strict
LDFLAGS	   += --summary_stderr 
LDFLAGS    += --xref 
LDFLAGS    += --callgraph 
LDFLAGS	   += --partial 
ifeq ($(ARCH_M3),1)
LDFLAGS	   += --cpu Cortex-M3 --li
endif
ifeq ($(ARCH_M3),0)
LDFLAGS	   += --cpu ARM966E-S
endif

#---------------------------------------------------------------------------
# Implicit rules
#---------------------------------------------------------------------------
.c.o:
	$(CC) $(CFLAGS) -c -o $*.o $< $(INCLUDES)

.s.o:
	$(ASM) $(ASMFLAGS) -o $*.o $< $(INCLUDES)

#---------------------------------------------------------------------------
# Explicit ruls
#---------------------------------------------------------------------------
OBJ_FILES	= $(C_SRC:%.c=%.o) $(ASM_SRC:%.s=%.o)

all:$(GOAL)

$(GOAL) : $(OBJ_FILES)
	$(LD) $(OBJ_FILES) $(LDFLAGS) --output $@

clean:
	$(RM) -f $(OBJ_FILES:.o=.d) $(OBJ_FILES) $(GOAL).*
